<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        Array.prototype.unique = function() {
            var temp = {},
                arr = [],
                len = this.length;
            for (var i = 0; i < len; i++) {
                // 将数组元素作为对象属性,判断对象中是否有该属性,如果没有就添加属性,并放入arr数组
                if (!temp[this[i]]) {
                    temp[this[i]] = "abc";
                    arr.push(this[i])
                }
            }
            return arr;
        }
    </script>
</body>

</html>